package LECONGHAU.LISTARRAY.BAI3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class VIEWS {
public static void main(String[] args) {
	List<Student> listStudent=new ArrayList<Student>();
	Student sv01=new Student();
	sv01.setRollNum(01);
	sv01.setFullName("le cong hau1");
	sv01.setMark(9.5);
	Student sv02=new Student();
	sv02.setRollNum(02);
	sv02.setFullName("le cong hau2");
	sv02.setMark(10);
	Student sv03=new Student();
	sv03.setRollNum(03);
	sv03.setFullName("le cong hau3");
	sv03.setMark(9);
	Student sv04=new Student();
	sv04.setRollNum(04);
	sv04.setFullName("le cong hau4");
	sv04.setMark(8.5);
	listStudent.add(sv01);
	listStudent.add(sv02);
	listStudent.add(sv03);
	listStudent.add(sv04);
	for(int i=0;i<listStudent.size();i++){
		System.out.println("---------"+(i+1)+"-----------------");
		System.out.println("RollNum: "+listStudent.get(i).getRollNum());
		System.out.println("FullName: "+listStudent.get(i).getFullName());
		System.out.println("Mark: "+listStudent.get(i).getMark());
	}
	Collections.sort(listStudent, new Comparator<Student>() {
		@Override
		public int compare(Student o1, Student o2) {
//           if(o1.getMark()>o2.getMark()){
//        	   return 1;
//           }
//           else if (o1.getMark()<o2.getMark()) {
//   			return -1;
//   		}else {
//   			return 0;
//   		}
		return o2.getFullName().compareTo(o1.getFullName());	
		}
	});
	for(int i=0;i<listStudent.size();i++){
		System.out.println("---------"+(i+1)+"-----------------");
		System.out.println("RollNum: "+listStudent.get(i).getRollNum());
		System.out.println("FullName: "+listStudent.get(i).getFullName());
		System.out.println("Mark: "+listStudent.get(i).getMark());
	}
	
}
}
